package leetcode.medium.convertToTitle;

class Solution {

    private static final int ALPHABET_SIZE = 26;
    private char digitToName(int digit) {
        return (char) ('A' + (digit - 1));
    }


    public String convertToTitle(int columnNumber) {
        StringBuilder builder = new StringBuilder();
        while (columnNumber > ALPHABET_SIZE) {
            builder.append(digitToName(columnNumber % ALPHABET_SIZE));
            columnNumber = columnNumber % ALPHABET_SIZE;
        }
        return builder.toString();
    }

    public static void main(String[] args) {
        System.out.println(new Solution().convertToTitle(2147483647));
    }
}
